import Vue from 'vue';
import axios from './router/axios';
import VueAxios from 'vue-axios';
import App from './App';
import router from './router/router';
import './permission'; // 权限
import './error'; // 日志
import './cache';//页面缓冲
import store from './store';
// import { loadStyle } from './util/util'
import * as urls from '@/config/env';
import Element from 'element-ui';
import 'element-ui/lib/theme-chalk/index.css';
// import {
//     iconfontUrl,
//     iconfontVersion
// } from '@/config/env';
import i18n from './lang' // Internationalization
import './styles/common.scss';
import AVUE from '@smallwei/avue';
import '@smallwei/avue/lib/index.css';
import '../public/iconfont/iconfont.css'
import '@/components/view';
import globalVariable from './const/global_variable';
import AvueFormDesign from '@sscfaith/avue-form-design';
import AvueUeditor from 'avue-plugin-ueditor';
import Chat from 'jwchat';
import Highcharts from 'highcharts';
import HighchartsVue from 'highcharts-vue';
// import FastClick from 'fastclick';
// import filters from './filters';

Vue.prototype.GLOBAL = globalVariable

import basicContainer from './components/basic-container/main'

// 引入图片放大插件
import Viewer from 'v-viewer'
import 'viewerjs/dist/viewer.css'
// Vue.use(Viewer)
// Viewer.setDefaults({
//   Options: { zIndexInline: 9999, zIndex: 9999, 'button': true, 'navbar': true, 'title': true, 'toolbar': true, 'tooltip': true, 'movable': true, 'zoomable': true, 'rotatable': true, 'scalable': true, 'transition': true, 'fullscreen': true, 'keyboard': true, 'url': 'data-source' }
// })
Vue.use(Viewer, {
    defaultOptions: { zIndex: 9999, toolbar: true } 
})

Vue.use(router)
Vue.use(VueAxios, axios)
Vue.use(Element, {
    i18n: (key, value) => i18n.t(key, value)
})
Vue.use(AVUE, {
    i18n: (key, value) => i18n.t(key, value)
})
Vue.use(AvueFormDesign)
Vue.use(AvueUeditor)
Vue.use(Chat)
Vue.use(HighchartsVue, {
    tagName: 'charts'
});
Highcharts.setOptions({
    credits: false
});

//注册全局容器
Vue.component('basicContainer', basicContainer)
// 加载相关url地址
Object.keys(urls).forEach(key => {
    Vue.prototype[key] = urls[key];
})

// // 动态加载阿里云字体库
// iconfontVersion.forEach(ele => {
//     loadStyle(iconfontUrl.replace('$key', ele));
// })
// filters(Vue);

Vue.config.productionTip = false;

// FastClick.attach(document.body);

new Vue({
    router,
    store,
    i18n,
    render: h => h(App)
}).$mount('#app')

window.addEventListener("onbeforeunload",()=>{
  console.log('refresh')
  Vue.$store.commit("SET_OBJ", { key: 'store', obj: store.state })
})